package com.tusiyou.homework;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


public class MeFragment extends Fragment {

    private String[] data = new String[]{"我的收藏","我的下载"};
    private String[] data2= new String[]{"推荐给好友","给个好评","设置"};
    private ListView lv1,lv2;
    public MeFragment() {
        // Required empty public constructor
    }



    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        LinearLayout ll = (LinearLayout) inflater.inflate(R.layout.fragment_me, container, false);
        lv1 = (ListView) ll.findViewById(R.id.listView_1);
        lv2 = (ListView) ll.findViewById(R.id.listView_2);
        List<HashMap<String,String>> mapList = new ArrayList<>();
        for (int i =0;i<data.length;i++){
            HashMap<String,String> map = new HashMap<>();
            map.put("text",data[i]);
            mapList.add(map);
        }
        List<HashMap<String,String>> mapList1 = new ArrayList<>();
        for (int i =0;i<data2.length;i++){
            HashMap<String,String> map1 = new HashMap<>();
            map1.put("text",data2[i]);
            mapList1.add(map1);
        }

        lv1.setAdapter(new SimpleAdapter(getActivity(),mapList,R.layout.me_item,new String[]{"text"},new int[]{R.id.me_tv}));
        lv2.setAdapter(new SimpleAdapter(getActivity(),mapList1,R.layout.me_item,new String[]{"text"},new int[]{R.id.me_tv}));

        return ll;

    }




}
